home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC & Mediji 1998 February
/
PCM_9802.iso
/
programi
/
director
/
data.z
/
Behavior Library.cst
/
00050_Script_UI Drag Snap to Sprite
< prev
next >
Wrap
Text File
|
1997-05-09
|
2KB
|
74 lines
-- Gesture Snap to Sprite
property snapDistance, snapTarget, xoffset, yoffset
property tracking, boxtop, boxleft, boxright,boxbottom
on beginsprite me
set boxtop = the locv of sprite snapTarget - snapDistance
set boxbottom = the locv of sprite snapTarget + snapDistance
set boxleft = the loch of sprite snapTarget - snapDistance
set boxright = the loch of sprite snapTarget + snapDistance
end
on prepareframe me
if tracking then
if inbox (me, the mouseH - xoffset, the mouseV - yoffset) then
snap me
else
set the locH of sprite the spritenum of me = the MouseH - xoffset
set the locV of sprite the spritenum of me = the MouseV - yoffset
end if
end if
end
on mousedown me
set tracking = TRUE
set xoffset = the mouseH - the locH of sprite the spritenum of me
set yoffset = the mouseV - the locV of sprite the spritenum of me
end
on mouseup me
set tracking = FALSE
end
on snap me
set the locH of sprite the spritenum of me = the locH of sprite snapTarget
set the locV of sprite the spritenum of me = the locV of sprite snapTarget
end
on inbox me,x,y
if x < boxright and x > boxleft and y < boxbottom and y > boxtop then
return 1
end if
return 0
end
---
on getPropertyDescriptionList
set p_list = [ ¼
#snapDistance: [ #comment: "Snap Distance:", ¼
#format: #integer, ¼
#default: 8 ], ¼
#snapTarget: [ #comment: "Target Sprite:", ¼
#format: #integer, ¼
#default: 1 ] ¼
]
return p_list
end
on getBehaviorDescription
return ¼
"Cause a sprite to snap to the registration point of the target sprite while being dragged. " & RETURN & ¼
"PARAMETERS:" & RETURN & ¼
"ò Snap Distance - Enter the range in pixels within which snapping occurs." & RETURN & ¼
"ò Snap Target - Enter the channel number of the sprite to snap to."
end